--[[ notes: this code please execute this code on cpp code
require'zmdbloader'
--or--
loadfile'./bin/zmdbloader.lua'()

--decode function, you can return complie value for secu
local function mydecode(k,v)
	return loadstring(mime.unb64(v,nil))
end
-- c version
/*
int mydecode(lua_State *L)
{
	const char *k = lua_tostring(L, 1);
	int l;
	const char *v = luaL_checklstring(L, 2, &l)
	//deocde v to nv
	....
	//,
	return luaL_loadbuffer(L,nv,nvsize,k)
}
void init(lua_State *L)
{
	lua_register(L, "mydecode", mydecode);
}
*/
--set require loader for the mod in zdc.mod
zmdbloader.getmod({'./zdc.mod',decode=mydecode})
--or for cache all and free db
zmdbloader.getmod({'./zdc.mod',decode=mydecode}):loadall()
]]

--[[ cmd line :
#please mkdir /workspace/build/zdc
#please del the zdc.mod file if needed

cd /workspace/zdc/tools
lua zdctosqlite.lua
#we will get the zdc.mod in /workspace/build/zdc/

#z.buildmod can accept the param filter to exculde some files, such as {"^/workspace/zdc/lua/zwsapi/.*"}
#z.buildmod can accept complie arg, you can use zdump for no debug info
]]
require'mime.core'
local function myencode(k,v)
	return mime.b64(v,nil)
end
local function mydecode(k,v)
	return mime.unb64(v,nil)
end

local outdir,zdcpath=...
outdir=outdir or [[/workspace/build/zdc]]
zdcpath=zdcpath or [[/workspace/zdc]]

dofile(zdcpath .. [[/bin/zmdbloader.lua]])
local z=zmdbloader
require'zdump'
z.buildmod(zdcpath .. '/lib/lua',{outdir..'/zdc.mod',encode=myencode,decode=mydecode})
z.buildmod(zdcpath .. '/lua',{outdir..'/zdc.mod',encode=myencode,decode=mydecode},nil,zdump)

